<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>cptsvx.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CPTSVX.1"></a><a href="cptsvx.f.html#CPTSVX.1">CPTSVX</a>( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX,
     $                   RCOND, FERR, BERR, WORK, RWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          FACT
      INTEGER            INFO, LDB, LDX, N, NRHS
      REAL               RCOND
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               BERR( * ), D( * ), DF( * ), FERR( * ),
     $                   RWORK( * )
      COMPLEX            B( LDB, * ), E( * ), EF( * ), WORK( * ),
     $                   X( LDX, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CPTSVX.23"></a><a href="cptsvx.f.html#CPTSVX.1">CPTSVX</a> uses the factorization A = L*D*L**H to compute the solution
</span><span class="comment">*</span><span class="comment">  to a complex system of linear equations A*X = B, where A is an
</span><span class="comment">*</span><span class="comment">  N-by-N Hermitian positive definite tridiagonal matrix and X and B
</span><span class="comment">*</span><span class="comment">  are N-by-NRHS matrices.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Error bounds on the solution and a condition estimate are also
</span><span class="comment">*</span><span class="comment">  provided.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Description
</span><span class="comment">*</span><span class="comment">  ===========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The following steps are performed:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  1. If FACT = 'N', the matrix A is factored as A = L*D*L**H, where L
</span><span class="comment">*</span><span class="comment">     is a unit lower bidiagonal matrix and D is diagonal.  The
</span><span class="comment">*</span><span class="comment">     factorization can also be regarded as having the form
</span><span class="comment">*</span><span class="comment">     A = U**H*D*U.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  2. If the leading i-by-i principal minor is not positive definite,
</span><span class="comment">*</span><span class="comment">     then the routine returns with INFO = i. Otherwise, the factored
</span><span class="comment">*</span><span class="comment">     form of A is used to estimate the condition number of the matrix
</span><span class="comment">*</span><span class="comment">     A.  If the reciprocal of the condition number is less than machine
</span><span class="comment">*</span><span class="comment">     precision, INFO = N+1 is returned as a warning, but the routine
</span><span class="comment">*</span><span class="comment">     still goes on to solve for X and compute error bounds as
</span><span class="comment">*</span><span class="comment">     described below.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  3. The system of equations is solved for X using the factored form
</span><span class="comment">*</span><span class="comment">     of A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  4. Iterative refinement is applied to improve the computed solution
</span><span class="comment">*</span><span class="comment">     matrix and calculate error bounds and backward error estimates
</span><span class="comment">*</span><span class="comment">     for it.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  FACT    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies whether or not the factored form of the matrix
</span><span class="comment">*</span><span class="comment">          A is supplied on entry.
</span><span class="comment">*</span><span class="comment">          = 'F':  On entry, DF and EF contain the factored form of A.
</span><span class="comment">*</span><span class="comment">                  D, E, DF, and EF will not be modified.
</span><span class="comment">*</span><span class="comment">          = 'N':  The matrix A will be copied to DF and EF and
</span><span class="comment">*</span><span class="comment">                  factored.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix A.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  NRHS    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of right hand sides, i.e., the number of columns
</span><span class="comment">*</span><span class="comment">          of the matrices B and X.  NRHS &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  D       (input) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The n diagonal elements of the tridiagonal matrix A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  E       (input) COMPLEX array, dimension (N-1)
</span><span class="comment">*</span><span class="comment">          The (n-1) subdiagonal elements of the tridiagonal matrix A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  DF      (input or output) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          If FACT = 'F', then DF is an input argument and on entry
</span><span class="comment">*</span><span class="comment">          contains the n diagonal elements of the diagonal matrix D
</span><span class="comment">*</span><span class="comment">          from the L*D*L**H factorization of A.
</span><span class="comment">*</span><span class="comment">          If FACT = 'N', then DF is an output argument and on exit
</span><span class="comment">*</span><span class="comment">          contains the n diagonal elements of the diagonal matrix D
</span><span class="comment">*</span><span class="comment">          from the L*D*L**H factorization of A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  EF      (input or output) COMPLEX array, dimension (N-1)
</span><span class="comment">*</span><span class="comment">          If FACT = 'F', then EF is an input argument and on entry
</span><span class="comment">*</span><span class="comment">          contains the (n-1) subdiagonal elements of the unit
</span><span class="comment">*</span><span class="comment">          bidiagonal factor L from the L*D*L**H factorization of A.
</span><span class="comment">*</span><span class="comment">          If FACT = 'N', then EF is an output argument and on exit
</span><span class="comment">*</span><span class="comment">          contains the (n-1) subdiagonal elements of the unit
</span><span class="comment">*</span><span class="comment">          bidiagonal factor L from the L*D*L**H factorization of A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B       (input) COMPLEX array, dimension (LDB,NRHS)
</span><span class="comment">*</span><span class="comment">          The N-by-NRHS right hand side matrix B.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array B.  LDB &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  X       (output) COMPLEX array, dimension (LDX,NRHS)
</span><span class="comment">*</span><span class="comment">          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDX     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array X.  LDX &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RCOND   (output) REAL
</span><span class="comment">*</span><span class="comment">          The reciprocal condition number of the matrix A.  If RCOND
</span><span class="comment">*</span><span class="comment">          is less than the machine precision (in particular, if
</span><span class="comment">*</span><span class="comment">          RCOND = 0), the matrix is singular to working precision.
</span><span class="comment">*</span><span class="comment">          This condition is indicated by a return code of INFO &gt; 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  FERR    (output) REAL array, dimension (NRHS)
</span><span class="comment">*</span><span class="comment">          The forward error bound for each solution vector
</span><span class="comment">*</span><span class="comment">          X(j) (the j-th column of the solution matrix X).
</span><span class="comment">*</span><span class="comment">          If XTRUE is the true solution corresponding to X(j), FERR(j)
</span><span class="comment">*</span><span class="comment">          is an estimated upper bound for the magnitude of the largest
</span><span class="comment">*</span><span class="comment">          element in (X(j) - XTRUE) divided by the magnitude of the
</span><span class="comment">*</span><span class="comment">          largest element in X(j).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  BERR    (output) REAL array, dimension (NRHS)
</span><span class="comment">*</span><span class="comment">          The componentwise relative backward error of each solution
</span><span class="comment">*</span><span class="comment">          vector X(j) (i.e., the smallest relative change in any
</span><span class="comment">*</span><span class="comment">          element of A or B that makes X(j) an exact solution).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace) COMPLEX array, dimension (N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RWORK   (workspace) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value
</span><span class="comment">*</span><span class="comment">          &gt; 0:  if INFO = i, and i is
</span><span class="comment">*</span><span class="comment">                &lt;= N:  the leading minor of order i of A is
</span><span class="comment">*</span><span class="comment">                       not positive definite, so the factorization
</span><span class="comment">*</span><span class="comment">                       could not be completed, and the solution has not
</span><span class="comment">*</span><span class="comment">                       been computed. RCOND = 0 is returned.
</span><span class="comment">*</span><span class="comment">                = N+1: U is nonsingular, but RCOND is less than machine
</span><span class="comment">*</span><span class="comment">                       precision, meaning that the matrix is singular
</span><span class="comment">*</span><span class="comment">                       to working precision.  Nevertheless, the
</span><span class="comment">*</span><span class="comment">                       solution and error bounds are computed because
</span><span class="comment">*</span><span class="comment">                       there are a number of situations where the
</span><span class="comment">*</span><span class="comment">                       computed solution can be more accurate than the
</span><span class="comment">*</span><span class="comment">                       value of RCOND would suggest.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      REAL               ZERO
      PARAMETER          ( ZERO = 0.0E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            NOFACT
      REAL               ANORM
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.158"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      REAL               <a name="CLANHT.159"></a><a href="clanht.f.html#CLANHT.1">CLANHT</a>, <a name="SLAMCH.159"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
      EXTERNAL           <a name="LSAME.160"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="CLANHT.160"></a><a href="clanht.f.html#CLANHT.1">CLANHT</a>, <a name="SLAMCH.160"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           CCOPY, <a name="CLACPY.163"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>, <a name="CPTCON.163"></a><a href="cptcon.f.html#CPTCON.1">CPTCON</a>, <a name="CPTRFS.163"></a><a href="cptrfs.f.html#CPTRFS.1">CPTRFS</a>, <a name="CPTTRF.163"></a><a href="cpttrf.f.html#CPTTRF.1">CPTTRF</a>, <a name="CPTTRS.163"></a><a href="cpttrs.f.html#CPTTRS.1">CPTTRS</a>,
     $                   SCOPY, <a name="XERBLA.164"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      NOFACT = <a name="LSAME.174"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( FACT, <span class="string">'N'</span> )
      IF( .NOT.NOFACT .AND. .NOT.<a name="LSAME.175"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( FACT, <span class="string">'F'</span> ) ) THEN
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
         INFO = -2
      ELSE IF( NRHS.LT.0 ) THEN
         INFO = -3
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -9
      ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
         INFO = -11
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.187"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CPTSVX.187"></a><a href="cptsvx.f.html#CPTSVX.1">CPTSVX</a>'</span>, -INFO )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( NOFACT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Compute the L*D*L' (or U'*D*U) factorization of A.
</span><span class="comment">*</span><span class="comment">
</span>         CALL SCOPY( N, D, 1, DF, 1 )
         IF( N.GT.1 )
     $      CALL CCOPY( N-1, E, 1, EF, 1 )
         CALL <a name="CPTTRF.198"></a><a href="cpttrf.f.html#CPTTRF.1">CPTTRF</a>( N, DF, EF, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Return if INFO is non-zero.
</span><span class="comment">*</span><span class="comment">
</span>         IF( INFO.GT.0 )THEN
            RCOND = ZERO
            RETURN
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the norm of the matrix A.
</span><span class="comment">*</span><span class="comment">
</span>      ANORM = <a name="CLANHT.210"></a><a href="clanht.f.html#CLANHT.1">CLANHT</a>( <span class="string">'1'</span>, N, D, E )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the reciprocal of the condition number of A.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CPTCON.214"></a><a href="cptcon.f.html#CPTCON.1">CPTCON</a>( N, DF, EF, ANORM, RCOND, RWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute the solution vectors X.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CLACPY.218"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'Full'</span>, N, NRHS, B, LDB, X, LDX )
      CALL <a name="CPTTRS.219"></a><a href="cpttrs.f.html#CPTTRS.1">CPTTRS</a>( <span class="string">'Lower'</span>, N, NRHS, DF, EF, X, LDX, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Use iterative refinement to improve the computed solutions and
</span><span class="comment">*</span><span class="comment">     compute error bounds and backward error estimates for them.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="CPTRFS.224"></a><a href="cptrfs.f.html#CPTRFS.1">CPTRFS</a>( <span class="string">'Lower'</span>, N, NRHS, D, E, DF, EF, B, LDB, X, LDX, FERR,
     $             BERR, WORK, RWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Set INFO = N+1 if the matrix is singular to working precision.
</span><span class="comment">*</span><span class="comment">
</span>      IF( RCOND.LT.<a name="SLAMCH.229"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Epsilon'</span> ) )
     $   INFO = N + 1
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CPTSVX.234"></a><a href="cptsvx.f.html#CPTSVX.1">CPTSVX</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
